<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    <head>
        <meta charset="UTF-8">
        <title>错误</title>
        <style>
            .box {
                margin: 50px auto 0;
                width: 500px;
                display: flex;
                flex-direction: column;
                justify-content: center;
                text-align: center;
            }

            h1 {
                font-size: 120px;
                margin: 0;
            }

            .reason {
                font-size: 34px;
                margin: 50px 0;
            }
        </style>
        <script>
            window.onload = function () {
                var span = document.getElementById("countdownL");
                var countdown = 5;
                var intervalId = setInterval(function () {
                    span.innerText = (--countdown) + '秒后返回主页';
                    if (countdown === 0) {
                        window.location = "<%=basePath%>news";
                        clearInterval(intervalId);
                    }
                }, 1000);
            }
        </script>
    </head>
    <body>
        <div class="box">
            <h1>
                错误
            </h1>
            <span class="reason">${text}！</span><br>
            <span id="countdownL">5秒后返回主页</span><br>
            <a href="<%=basePath%>news">立刻返回主页面</a>
        </div>

    </body>
</html>
